﻿<%@ Control Language="C#" %>
<%@ Register TagPrefix="Hi" Namespace="Hidistro.UI.SaleSystem.Tags" Assembly="Hidistro.UI.SaleSystem.Tags" %>
<%@ Import Namespace="Hidistro.UI.SaleSystem.CodeBehind" %>
<%@ Import Namespace="Hidistro.Core" %>
<Hi:Common_New_Header runat="server" SkinName="/ascx/JsNewTags/Skin-Common_New_Header.ascx" />
<script type="text/javascript" src="utility/jquery.artdialog.js"></script>
<script type="text/javascript" src="http://res.juseshop.com/utility/listtotart.js"></script>
<link type="text/css" rel="stylesheet" href="http://res.juseshop.com/utility/skins/opera.css" />
<link type="text/css" rel="stylesheet" href="http://res.juseshop.com/templates/master/jusekeji/style/ShoppingCart.css" />

<form runat="server">
    <div class="shopping_overall">
        <div id="isLogin" class="prompt" runat="server">
            <span class="wicon"></span>
            满减活动正在进行中，请登录！
           
            <a class="btn_1 ml10" href="/login.aspx?ReturnUrl=/ShoppingCart.aspx">立即登录</a>
        </div>
        <div id="ShoppingCart" runat="server">
            <div class="prompts">
                <h1>全部商品</h1>
            </div>
            <div style="clear: both; background: #e6e6e6; height: 2px; position: relative;"></div>
            <div class="overall_content">
                <div class="mians">
                    <div class="overall_content_nav">
                        <div class="cart_checkbox">
                            <input class="jdcheckbox wnxd_qx" type="checkbox" checked="checked">全选
                       
                        </div>
                        <div class="columnt_goods">商品</div>
                        <div class="columnt_props"></div>
                        <div class="columnt_price">单价(元)</div>
                        <div class="columnt_quantity">数量</div>
                        <div class="columnt_sum">小计(元)</div>
                        <div class="columnt_action">操作</div>

                    </div>
                    <div class="cart_checkboxsx">
                        <a href="javascript:void(0);">&nbsp; 普通订单 &nbsp;</a><span style="font:12px tahoma,arial,'Hiragino Sans GB',\5b8b\4f53,sans-serif;color: #423F3F; text-decoration: none; float: left; padding-top: 13px; margin-left: 10px">优惠信息：
                            <asp:Literal runat="server" ID="promotionname"></asp:Literal></span>
                    </div>
                    <div class="dandu_one">
                        <Hi:wnxd_ShoppingCart_ProductList ID="productlist" runat="server" />
                    </div>
                    <div id="PromotionsList" runat="server" visible="false">
                        <div class="cart_checkboxsx">
                            <a href="javascript:void(0);">&nbsp; 活动专区 &nbsp;</a>
                        </div>
                        <Hi:wnxd_ShoppingCart_Promotions ID="promotions" runat="server" />
                    </div>
                </div>
                <div class="cart_floatbar">
                    <div class="select_all">
                        <div class="cart_checkboxsss">
                            <input class="jdcheckbox wnxd_qx" type="checkbox" checked="checked">全选
                       
                        </div>
                        <div class="operation">
                            <a id="wnxd_deleteAll" href="javascript:void(0);">删除选中的商品</a>
                            <a id="wnxd_favoritesAll" href="javascript:void(0);">移到我的关注</a>
                        </div>
                    </div>
                    <div class="comm_right">
                        <div class="right_left">
                            <p>已选择<asp:Label ID="Quantity" runat="server" Text="0"></asp:Label>件商品 ∧ 总价（不含运费）：<span>￥<asp:Label ID="Total" runat="server" Text="0.00"></asp:Label></span></p>
                            <p>已节省：￥<asp:Label ID="Amount" runat="server" Text="0.00"></asp:Label></p>
                        </div>
                        <div class="right_right">
                            <a id="wnxd_buy" href="javascript:void(0);">去结算</a>
                        </div>
                    </div>
                </div>
                <div class="shanchude" runat="server" visible="false">
                    <p>已删除商品，您可以重新购买或加关注：</p>
                    <div class="chanchu_cp">
                        <div class="kky">
                            <p><a href="#">性感流苏束胸式情趣内衣(含T裤) 展现迷人</a></p>
                        </div>
                        <div class="kkq">
                            <p>￥129.00</p>
                        </div>
                        <div class="kkx">
                            <p>1</p>
                        </div>
                        <div class="kkh"><a href="#">重新购买</a><a href="#">移到我的关注</a></div>
                    </div>
                </div>
            </div>

        </div>
        <script type="text/javascript">
            $.format = function (source, params) { 
                if (arguments.length == 1) 
                    return function () { 
                        var args = $.makeArray(arguments); 
                        args.unshift(source); 
                        return $.format.apply(this, args); 
                    }; 
                if (arguments.length > 2 && params.constructor != Array) { 
                    params = $.makeArray(arguments).slice(1); 
                } 
                if (params.constructor != Array) { 
                    params = [params]; 
                } 
                $.each(params, function (i, n) { 
                    source = source.replace(new RegExp("\\{" + i + "\\}", "g"), n); 
                }); 
                return source; 
            }; 
            (function () {
                var $select = $("[name='ProductID']"),
                    $Total = $("#ShoppingCart___Total"),
                    $Quantity = $("#ShoppingCart___Quantity"),
                    $Amount = $("#ShoppingCart___Amount");
                $(".ttghj").click(function () {
                    var $parent = $(this).parent(),
                        $this = $parent.children(".itxt");
                    $parent = $parent.parent().parent().parent();
                    var $price = parseInt($parent.children(".cell_p_price").find("span").text()),
                        $sum = $parent.children(".cell_p_sum").find("span"),
                        $sku = $parent.parent().prev().children("[name='ProductID']").val(),
                        $v = parseInt($this.val());
                    if ($v > 1) {
                        $v--;
                        var list = [];
                        for (var i = 0; i < $select.length; i++) {
                            var $t = $select[i];
                            if (!$t.checked) list.push($t.value);
                        }
                        $.post(location.href, "wnxd_Ajax=UpdateNum&num=" + $v + "&SkuId=" + $sku + "&list=" + JSON.stringify(list), function (e) {
                            if (e.error) {
                                art.dialog({
                                    title: "错误",
                                    content: e.msg,
                                    cancel: true,
                                    fixed: true
                                });
                            }
                            else {
                                $this.val($v);
                                $sum.text(($price * $v).toFixed(2));
                                $Total.text(e.total.toFixed(2));
                                $Quantity.text(e.quantity);
                                $Amount.text(e.amount.toFixed(2));
                                location.reload();
                            }
                        }, "json");
                    }
                });
                $(".ttght").click(function () {
                    var $parent = $(this).parent(),
                        $this = $parent.children(".itxt");
                    $parent = $parent.parent().parent().parent();
                    var $price = parseInt($parent.children(".cell_p_price").find("span").text()),
                        $sum = $parent.children(".cell_p_sum").find("span"),
                        $sku = $parent.parent().prev().children("[name='ProductID']").val(),
                        $v = parseInt($this.val());
                    $v++;
                    var list = [];
                    for (var i = 0; i < $select.length; i++) {
                        var $t = $select[i];
                        if (!$t.checked) list.push($t.value);
                    }
                    $.post(location.href, "wnxd_Ajax=UpdateNum&num=" + $v + "&SkuId=" + $sku + "&list=" + JSON.stringify(list), function (e) {
                        if (e.error) {
                            art.dialog({
                                title: "错误",
                                content: e.msg,
                                cancel: true,
                                fixed: true
                            });
                        }
                        else {
                            $this.val($v);
                            $sum.text(($price * $v).toFixed(2));
                            $Total.text(e.total.toFixed(2));
                            $Quantity.text(e.quantity);
                            $Amount.text(e.amount.toFixed(2));
                            location.reload();
                        }
                    }, "json");
                });
                var $oldC;
                $(".itxt").one("focus", function () {$oldC = this.value;}).keydown(function (obj) {
                    var key = window.event ? obj.keyCode : obj.which;
                    if (key == 13) {
                        $(this).blur();
                        return false;
                    }
                }).blur(function () {
                    var $this = $(this);
                    if ($this.val() == "") {
                        $this.focus();
                        return false;
                    }
                    var $parent = $this.parent();
                    $parent = $parent.parent().parent().parent();
                    var $price = parseInt($parent.children(".cell_p_price").find("span").text()),
                        $sum = $parent.children(".cell_p_sum").find("span"),
                        $sku = $parent.parent().prev().children("[name='ProductID']").val(),
                        $v = parseInt($this.val());
                    var list = [];
                    for (var i = 0; i < $select.length; i++) {
                        var $t = $select[i];
                        if (!$t.checked) list.push($t.value);
                    }
                    $.post(location.href, "wnxd_Ajax=UpdateNum&num=" + $v + "&SkuId=" + $sku + "&list=" + JSON.stringify(list), function (e) {
                        if (e.error) {
                            art.dialog({
                                title: "错误",
                                content: e.msg,
                                cancel: true,
                                fixed: true
                            });
                            $this.val($oldC);
                        }
                        else {
                            $this.val($v);
                            $sum.text(($price * $v).toFixed(2));
                            $Total.text(e.total.toFixed(2));
                            $Quantity.text(e.quantity);
                            $Amount.text(e.amount.toFixed(2));
                        }
                        $this.one("focus", function () { $oldC = this.value; });
                    }, "json");
                }).keyup(function () {
                    if (this.value.length == 1) {
                        this.value = this.value.replace(/[^1-9]/g, '');
                    } else {
                        this.value = this.value.replace(/\D/g, '');
                    }
                }).bind("onbeforepaste", function () {
                    var str = clipboardData.getData('text');
                    if (str.length == 1) {
                        str = str.replace(/[^1-9]/g, '');
                    }
                    else {
                        str = str.replace(/\D/g, '');
                    }
                    clipboardData.setData('text', str);
                });
                var NotSelect = <%=((wnxd_ShoppingCart)this.Parent).List%>,
                    $wnxd_qx = $(".wnxd_qx");
            if (NotSelect != undefined && NotSelect.length > 0){
                $wnxd_qx.attr("checked", false);
                for(var i=0;i<NotSelect.length;i++){
                    $("[name='ProductID'][value='"+NotSelect[i]+"']").attr("checked",false);
                }
            }
            $wnxd_qx.click(function () {
                $wnxd_qx.attr("checked", this.checked);
                $select.attr("checked", this.checked);
                var list = [];
                for (var i = 0; i < $select.length; i++) {
                    var $this = $select[i];
                    if (!$this.checked) list.push($this.value);
                }
                if ($(".prompt").length == 0) {
                    var $form = $('<form method="post" action="'+location.href+'"></form>').hide();
                    $('<input type="hidden" name="list" />').val(JSON.stringify(list)).appendTo($form);
                    $form.appendTo("body");
                    $form.submit();
                    return;
                }
                $.post(location.href, "wnxd_Ajax=UpdateList&list=" + JSON.stringify(list), function (e) {
                    if (e.error) {

                    }
                    else {
                        $Total.text(e.total.toFixed(2));
                        $Quantity.text(e.quantity);
                        $Amount.text(e.amount.toFixed(2));
                    }
                }, "json");
            });
            $select.click(function () {
                var list = [];
                for (var i = 0; i < $select.length; i++) {
                    var $this = $select[i];
                    if (!$this.checked) list.push($this.value);
                }
                if ($(".prompt").length == 0) {
                    var $form = $('<form method="post" action="'+location.href+'"></form>').hide();
                    $('<input type="hidden" name="list" />').val(JSON.stringify(list)).appendTo($form);
                    $form.appendTo("body");
                    $form.submit();
                    return;
                }
                if (!$select.is("[checked]")) {
                    $wnxd_qx.attr("checked", false);
                }
                else if ($select.not("[checked]").length == 0) {
                    $wnxd_qx.attr("checked", true);
                }
                $.post(location.href, "wnxd_Ajax=UpdateList&list=" + JSON.stringify(list), function (e) {
                    if (e.error) {

                    }
                    else {
                        $Total.text(e.total.toFixed(2));
                        $Quantity.text(e.quantity);
                        $Amount.text(e.amount.toFixed(2));
                    }
                }, "json");
            });
            $(".wnxd_delete").click(function(){
                var $this = $(this).parent().parent().parent().parent().prev().children("[name='ProductID']")[0],
                    $sku = $this.value;
                $.post(location.href, "wnxd_Ajax=DeleteList&list=[" + $sku + "]", function (e) {
                    if (e.error) {
                        art.dialog({
                            title: "错误",
                            content: e.msg,
                            cancel: true,
                            fixed: true
                        });
                    }
                    else {
                        var list = [];
                        for (var i = 0; i < $select.length; i++) {
                            var $t = $select[i];
                            if ($t != $this  && !$t.checked) list.push($t.value);
                        }
                        var $form = $('<form method="post" action="'+location.href+'"></form>').hide();
                        $('<input type="hidden" name="list" />').val(JSON.stringify(list)).appendTo($form);
                        $form.appendTo("body");
                        $form.submit();
                    }
                }, "json");
            });
            $("#wnxd_deleteAll").click(function(){
                var list = [];
                for (var i = 0; i < $select.length; i++) {
                    list.push($select[i].value);
                }
                $.post(location.href, "wnxd_Ajax=DeleteList&list=" + JSON.stringify(list), function (e) {
                    if (e.error) {
                        art.dialog({
                            title: "错误",
                            content: e.msg,
                            cancel: true,
                            fixed: true
                        });
                    }
                    else{
                        location.reload();
                    }
                }, "json");
            });
            $("#wnxd_buy").click(function(){
                var list = [];
                for (var i = 0; i < $select.length; i++) {
                    var $t = $select[i];
                    if (!$t.checked) list.push($t.value);
                }
                location.href = "<%=Globals.GetSiteUrls().UrlData.FormatUrl("submitOrder")%>?NotBuy=" + JSON.stringify(list);
                });
            $(".wnxd_add_wdgz").click(function(){
                if ($(".prompt").length == 0) {
                    $.get($.format("<%=Globals.GetSiteUrls().UrlData.FormatUrl("user_Favorites")%>",$(this).attr("pid")),function(){
                            var list = [];
                            for (var i = 0; i < $select.length; i++) {
                                var $t = $select[i];
                                if (!$t.checked) list.push($t.value);
                            }
                            var $form = $('<form method="post" action="'+location.href+'"></form>').hide();
                            $('<input type="hidden" name="list" />').val(JSON.stringify(list)).appendTo($form);
                            $form.appendTo("body");
                            $form.submit();
                        });
                    }
                    else{
                        art.dialog({
                            title: "错误",
                            content: "需要登录后才能添加",
                            cancel: true,
                            fixed: true
                        });
                    }
                });
            $("#wnxd_favoritesAll").click(function(){
                if ($(".prompt").length == 0) {
                    var $pids = $(".wnxd_add_wdgz");
                    for(var i=0;i<$pids.length;i++){
                        $.get($.format("<%=Globals.GetSiteUrls().UrlData.FormatUrl("user_Favorites")%>",$pids.eq(i).attr("pid")));
                        }
                        setTimeout(function(){
                            var list = [];
                            for (var i = 0; i < $select.length; i++) {
                                var $t = $select[i];
                                if (!$t.checked) list.push($t.value);
                            }
                            var $form = $('<form method="post" action="'+location.href+'"></form>').hide();
                            $('<input type="hidden" name="list" />').val(JSON.stringify(list)).appendTo($form);
                            $form.appendTo("body");
                            $form.submit();
                        },1000);
                    }
                    else{
                        art.dialog({
                            title: "错误",
                            content: "需要登录后才能添加",
                            cancel: true,
                            fixed: true
                        });
                    }
                });
        })();
        </script>
        <div class="cainixihuan">
            <div class="cainixihuan_top">
                <ul id="lb_list">
                    <li class="lb_li"><a href="javascript:void(0);">猜你喜欢</a></li>
                    <li id="wnxd_wdgz" runat="server" visible="false"><a href="javascript:void(0);">我的关注</a></li>
                    <li><a href="javascript:void(0);">最近浏览</a></li>
                </ul>
            </div>
            <div class="cainixihuan_bottom">
                <div class="anniu_left">
                    <a href="javascript:void(0);">
                        <img src="http://image.juseshop.com//UploadImage/AdvertImg/zuobian.png" /></a>
                </div>
                <div class="ul_list">
                    <ul>
                        <Hi:wnxd_Shopping_LiList ID="cainixihuan" runat="server" />
                    </ul>
                    <ul id="wnxd_wdgz_list" style="display: none;" class="ul_list" runat="server" visible="false">
                        <Hi:wnxd_Shopping_LiList ID="favorites" runat="server" />
                    </ul>
                    <ul style="display: none;" class="ul_list">
                        <Hi:wnxd_Shopping_LiList ID="history" runat="server" />
                    </ul>
                </div>
                <div class="anniu_right">
                    <a href="javascript:void(0);">
                        <img src="http://image.juseshop.com/UploadImage/AdvertImg/youbian.png" /></a>
                </div>
            </div>
        </div>
        <script type="text/javascript">
            (function () {
                var $ul = $(".ul_list").children("ul").each(function () {
                    var $this = $(this).css({ "position": "relative", "top": 0, "left": 0 }),
                        $li = $this.children("li");
                    $this.width(($li.width() + parseInt($li.css("padding-left")) * 2) * $li.length);
                }),
                    $w = $ul.parent().width(),
                    isok = true;
                $("#lb_list").children("li").each(function (index) {
                    var $this = $(this);
                    $this.mousemove(function () {
                        $("li.lb_li").removeClass("lb_li");
                        $this.addClass("lb_li");
                        isok = false;
                        $ul.stop(true, false).hide().eq(index).animate({ "left": 0 }, 500, function () { isok = true; }).show();
                    });
                });
                $(".anniu_left").click(function () {
                    var $this = $(".ul_list ul:visible"),
                        $left = parseInt($this.css("left"));
                    if (isok && $left < 0) {
                        isok = false;
                        $this.animate({ "left": $left + $w }, 500, function () { isok = true; });
                    }
                });
                $(".anniu_right").click(function () {
                    var $this = $(".ul_list ul:visible"),
                        $left = parseInt($this.css("left"));
                    if (isok && $left > -((Math.ceil($this.width() / $w) - 1) * $w)) {
                        isok = false;
                        $this.animate({ "left": $left - $w }, 500, function () { isok = true; });
                    }
                });
            })();
        </script>
    </div>
</form>
<Hi:Common_New_Footer runat="server" />
